<?php
class Securities extends CI_Controller {
	/*
	 Controllers that are considered secure extend Secure_area, optionally a $module_id can
	 be set to also check if a user can access a particular module in the system.
	 */
	function __construct($module_id = null) {
		parent::__construct();
		if (!$this -> mod_users -> is_logged_in()) {
			redirect('errors/error_404');
			
			//redirect('welcome/not_found');
		}

		if (!$this -> mod_users -> has_permission($module_id, $this -> mod_users -> get_logged_in_user_info() -> user_id) && !$this -> mod_users -> has_permission_group($module_id, $this -> mod_users -> get_logged_in_user_info() -> use_user_group_id)) {

			redirect('ctme-common/no-allow-access/' . str_replace('_','-', $module_id));
		}

		//load up global data
		$logged_in_user_info = $this -> mod_users -> get_logged_in_user_info();
		//$data['allowed_modules']=$this->Module->get_allowed_modules($logged_in_employee_info->person_id);
		$data['user_info'] = $logged_in_user_info;
		$this -> load -> vars($data);
	}

	public function is_has_modify_permission($module_id = null) {

		if (!$this -> mod_users -> is_has_modify_permission($module_id, $this -> mod_users -> get_logged_in_user_info() -> user_id) && !$this -> mod_users -> is_has_modify_permission_group($module_id, $this -> mod_users -> get_logged_in_user_info() -> use_user_group_id)) {
			return FALSE;
		} else {
			return TRUE;
		}
	}

}
